﻿using Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinCourseControls
{
    public partial class FrmMonthCalendar : Form
    {
        public FrmMonthCalendar()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 日期范围发生改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            txtStart.Text = monthCalendar1.SelectionStart.ToString("yyyy-MM-dd HH:mm:ss");
            txtEnd.Text = monthCalendar1.SelectionEnd.ToString("yyyy-MM-dd HH:mm:ss");
        }

        /// <summary>
        /// 单选按钮事件-设置是否显示周数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rbShow_CheckedChanged(object sender, EventArgs e)
        {
            if (rbShow.Checked)
                monthCalendar1.ShowWeekNumbers = true; // 显示周数
            else
                monthCalendar1.ShowWeekNumbers = false; // 不显示周数
        }

        /// <summary>
        /// 复选框事件-设置是否显示今天日期
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chkShowToday_CheckedChanged(object sender, EventArgs e)
        {
            if (chkShowToday.Checked)
                monthCalendar1.ShowToday = true;  // 显示今天日期
            else
                monthCalendar1.ShowToday = false;  // 不显示今天日期
        }

        /// <summary>
        /// 确定按钮-设置最大连续选择天数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSet_Click(object sender, EventArgs e)
        {
            if (txtMaxDays.Text.GetInt()>0)
                monthCalendar1.MaxSelectionCount = txtMaxDays.Text.GetInt(); // 设置最大连续选择天数
        }
    }
}
